package com.jnc.web.support.service;

import com.jnc.web.biz.system.model.DictData;
import com.jnc.web.biz.system.service.DictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: jjn
 * @Date: 2018/11/7
 * @Desc: html调用 thymeleaf，实现字典取值
 */
@Service("dict")
public class DictService {

    @Autowired
    private DictDataService dictDataService;

    /**
     * 根据字典类型，获取字典数据列表
     * @param dictType
     * @return
     */
    public List<DictData> getData(String dictType){
        return dictDataService.getDictDataByType(dictType);
    }

    /**
     * 根据字典类型、字典编码，获取字典值(先从缓存取，缓存没有再从数据库取。服务端项目已加载到redis)
     * @param dictType
     * @param dictCode
     * @return
     */
    public String getValue(String dictType, String dictCode){
        return dictDataService.getValueBy(dictType, dictCode);
    }

}
